package com.lyn.andplugin.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.lyn.andplugin.databinding.AdaterPluginItemBinding
import com.lyn.pluginapi.entity.PluginInfo
import com.lyn.pluginapi.entity.WrapPluginInfo
import com.lyn.ui.adapter.BaseAdapter
import com.lyn.ui.adapter.viewHolder.BaseViewHolder

/**
 *
 * @author longyn 2025/07/10
 * @version 1.0.0
 */
class PluginAdapter : BaseAdapter<WrapPluginInfo>() {
    override fun onMyBindViewHolder(holder: BaseViewHolder, position: Int) {
        getItem(position)?.let { item->
            val binding = holder.binding
            if (binding is AdaterPluginItemBinding){
                binding.name.text = item.pluginInfo.name
                binding.logo.setImageBitmap(item.logo)
            }
        }
    }

    override fun onMyCreateViewHolder(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): BaseViewHolder {
        val binding = AdaterPluginItemBinding.inflate(layoutInflater, parent, false)
        return BaseViewHolder(binding)
    }
}